package Modelo.DAL;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.json.JSONObject;

/**
 *
 * @author Alberto Sanchez
 */
public class TipoRiesgo_DAO {

    public TipoRiesgo_DAO() {
    }

    //Modulo 2
    public String[] listTipoRiesgo() {
        ConexionBD conexion = new ConexionBD();
        if (conexion.session == null) {
            return null;
        }
        Statement s = null;
        try {
            s = conexion.session.createStatement();
            String query = "SELECT nombre FROM TIPO_RIESGO";
            ResultSet rs = s.executeQuery(query);
            conexion.session.setHoldability(rs.HOLD_CURSORS_OVER_COMMIT);

            String[] tipoR = new String[5];
            int i = 0;
            while (rs.next()) {
                tipoR[i++] = rs.getString(1);
            }
            rs.close();
            return tipoR;
        } catch (SQLException se) {
            System.out.println("Error Consultando Espacios!\n");
            return null;
        } finally {
            if (conexion != null) {
                conexion.cerrarConexion();
            }
        }


    }
}
